<script setup lang="ts">
  import { ref, defineEmits, watch, onMounted, computed } from 'vue';
  import { useBooleanStore } from '@/store';
  import { searchByPage } from '@/api/material-receipt';

  const emit = defineEmits(['updateArray']);
  const booleanStore = useBooleanStore();
  // 表单查询数据
  const pageSize = ref<number>(30);
  const pageNumber = ref<number>(1);

  // 发送搜索数据

  // 表格数据
  async function handleSearch() {
    const info = ref({
      funcType: 'putIntoStorage',
      searchParams: {
        itemCode: '',
        qualityCode: '',
        mProductNumber: '',
      },
      pageParameter: {
        rows: computed(() => pageSize.value),
        page: computed(() => pageNumber.value),
      },
    });
    const newData: any = await searchByPage(info.value);
    emit('updateArray', newData);
  }

  onMounted(() => {
    handleSearch();
  });
  // 监听分页
  watch([() => booleanStore.pageNum, () => booleanStore.pageSize], () => {
    if (booleanStore.num5 === 9) {
      pageNumber.value = booleanStore.pageNum;
      pageSize.value = booleanStore.pageSize;
      handleSearch();
    }
  });
  defineExpose({ handleSearch });
</script>

<template> <div></div></template>

<style scoped>
  .margin-top {
    margin-top: 10px;
  }
  .btn-group {
    float: right;
    margin-top: 15px;
  }

  .btn-reset {
    margin-left: 10px;
  }
  .font {
    font-size: 20px;
    color: black;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
      Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue',
      sans-serif;
  }
  .div-tips {
    align-items: center;
    text-align: center;
    color: #999;
  }
</style>
